package com.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.common.utils.DateUtil;
import com.common.utils.RedisUtils;
import com.common.utils.Result;
import com.entity.Operation;
import com.mapper.OperationMapper;
import com.service.OperationService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wty
 * @since 2021-04-19
 */
@Service
public class OperationServiceImpl extends ServiceImpl<OperationMapper, Operation> implements OperationService {

    /**
     * 根据条件，获得操作记录
     * @param operation
     * @return
     */
    @Override
    public Result getOperationList(Operation operation) {

        Wrapper<Operation> wr=new EntityWrapper<>();
        if(null!=operation.getTaskStoreId()){
            wr.eq("task_store_id",operation.getTaskStoreId());
        }
        List<Operation> operations = this.selectList(wr);

        for (Operation vo : operations) {
            String name = RedisUtils.nameMap.get(vo.getTaskStoreId());
            vo.setTaskStoreName(name);
            Long addTime = vo.getAddTime();
            String time = DateUtil.stampToDate(addTime*1000 + "");
            vo.setAddTimeStr(time);
        }
        return Result.success(operations);
    }




}
